User's guide /

/

Document Templates

Document Templates

Overview

The OBS ERP document templates module allows you to present information stored in the OBS ERP modules as PDF documents. For example, you can create:

  • A custom template for module Finance -> Income that contains a branded invoice aligned with domestic legislation
  • A template for module "Contracts" which holds information about the standard contract you sign with your customers

Template Processing Engine

OBS ERP is equipped with a template processing engine called OB1, developed by OBS ERP. It can convert template variables to text. For example:

  • In the "Contracts" module, you can use a variable like ~~date_of_issue~~
  • OBS ERP will convert this variable to the actual date of issue of the contract

Accessing Templates

Document templates can be found in module Administration -> Templates -> Docs. OBS ERP comes with a default set of templates for some of the main modules (Invoices, Quotations, Vacations, etc.).

Note: Do not forget to make a backup of the original template before making any changes

Editing Templates

Let's open one of the most complex default templates - Invoices (navigate to Administration -> Templates -> Docs -> Edit row 1).

Template Edit

Fig. 1: Template editing interface

In the template editor, you can:

  • Set the font type and size
  • Add header and footer to the template
  • Control the paging
  • Select the modules where the template will be applied (click on the 'Modules' button in the top left corner)

Editing Template Contents

Click the "Text" input field to open the template contents:

Template Contents

Fig. 2: Template contents editing

To change the contents of a template:

  1. Make your changes
  2. Click the "Save" button (highlighted in red in Fig. 2)
  3. Click the "Reload Templates" button (highlighted in blue in Fig. 2)

To see the end result:

  1. Open the target module (e.g., "Income")
  2. Create a record
  3. Click on the PDF button above the record

Template Processor Features

The template processor supports the following features:

  • Variables
  • Functions
  • Text replacement
  • Loops
  • Conditional evaluation

Showing Available Variables

To check which variables are available for a specific module:

    1. Write the following function anywhere in the template:
~.show_vars.~
  1. Click save and reload
  2. The result will be visible in the target module, for example:
VAR VALUE
amount 8700.00
contract_id 2015-09-23 №28 Test Customer

Using Variables

To display the value of a variable, use the following enclosing sequence:

~~variable~~

Example:

~~invoice_id~~

Result (invoice number): 14

Translating Keywords

To translate a keyword as per the definitions in the "Translations" module, use:

~_variable_~

Example:

~_qty_~

Creating Tables with Values

Table with Automatic Layout

Enclosing sequence:

~#table_name^table #~

Example:

~#invoice_items^table;#~

Table with Custom Columns

Enclosing sequence:

~#table_name^table; ~column_one~ ~column_two~ ~column_three~ #~

Example:

~#invoice_items^table; ~SEQ~ ~name~ ~qty~ ~price_per_unit~ ~discount~ ~line_total~#~

Functions

General syntax for functions:

~.function_name^param1,param2,......~

Example:

~.translate^bottle.~

Importing Templates

You can import a template into another template using the following syntax:

~.import^template_name.~

Date Formatting

Examples of date formatting:

~.format_date^~created_at~,2006-01-02.~
~.format_time_to_date^~created_at~.~
~.format_time_to_minute^~created_at~.~
~.format_time_to_date_with_format^~created_at~,'2006-01-02 15:04'.~

Printing Statuses

If the module contains a field "status_id" and auditing is enabled, you can print a table containing information on who changed the status of the record and when. Example:

<div class="grid" style="display: grid; width: 100%; grid-template-columns: 33% 33% 33%; column-gap: 0.5rem; row-gap: 0.5rem;">
<div style="font-weight: bold;">~_time_~</div>
<div style="font-weight: bold;">~_employee_~</div>
<div style="font-weight: bold;">~_status_~</div>
{{ range $a, $b := $.Statuses }}
<div style="border: solid 1px #ececec;">{{ format_time_to_minute $b.Time }}:</div>
<div>{{ $b.Employee }} -></div>
<div>{{ $b.Status }}</div>
{{ end }}</div>